<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>once</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.js"></script>
</head>

<body>
  <button id="myButton">点击</button>
  <script>
    // _.once(func)
    // 创建一个只能调用 func 一次的函数
    const button = document.getElementById('myButton');
    let print = () => {
      console.log('text');
    }
    let test = _.once(print)
    button.addEventListener('click', test);
  </script>
</body>

</html>